<?php
date_default_timezone_set("PRC");
header("Content-type: text/html; charset=utf-8");
session_start();
//解除恶意调用
define('IN_TG',true);
//引入全局配置文件
require dirname(__FILE__).'/common.config.php';
//引入函数库
require dirname(__FILE__).'/common.func.php';
//数据库连接参数
require dirname(__FILE__).'/common.inc.php';
//引入数据库操作函数库
require dirname(__FILE__).'/mysqli.class.php';

//实例化数据库
$db = New Mysql(DB_HOST,DB_USER,DB_PWD,DB_NAME);

//检查外部传递的值并转义
function _RunMagicQuotes(&$svar)
{
	//PHP5.4已经将此函数移除
    if(@!get_magic_quotes_gpc())
    {
        if(is_array($svar))
        {
            foreach($svar as $_k => $_v) $svar[$_k] = _RunMagicQuotes($_v);
        }
        else
        {
            if(strlen($svar)>0 &&
			   preg_match('#^(cfg_|GLOBALS|_GET|_POST|_SESSION|_COOKIE)#',$svar))
            {
				exit('不允许请求的变量值!');
            }

            $svar = addslashes($svar);
        }
    }
    return $svar;
}


//直接应用变量名称替代
foreach(array('_GET','_POST') as $_request)
{
	foreach($$_request as $_k => $_v)
	{
		if(strlen($_k)>0 &&
		   preg_match('#^(GLOBALS|_GET|_POST|_SESSION|_COOKIE)#',$_k))
		{
			exit('不允许请求的变量名!');
		}

		${$_k} = _RunMagicQuotes($_v);
	}
}

//手机访问的
if (ismobile()) {
    $php_self=$_SERVER['PHP_SELF'];
    $m_url='Location:http://m.hongfund.com/';
    switch ($php_self) {
        case '/school/content.php':
            $id=intval($_GET['id']);
            header($m_url.'school/content.php?id='.$id);
            break;
        case '/school/index.php':
            header($m_url.'school/');
            break;
        case '/service/hongfengzhuce.php':
            header($m_url.'service/zhuce.php');
            break;
        case '/service/hongfengjizhang.php':
            header($m_url.'service/jizhang.php');
            break;
        case '/service/diyadaikuan.php':
            header($m_url.'service/daikuan.php');
            break;
        default:
            header($m_url);
            break;
    }
}
?>